<?php

namespace App\Models;

use Dcat\Admin\Admin;
use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Model;

class MemberTask extends Model
{
	use HasDateTimeFormatter;
    use SoftDeletes;

    //1为紧急，2为高，3为中，4为低
    const TASK_PRIORITY_EMERGENCY = 1;
    const TASK_PRIORITY_HIGH = 2;
    const TASK_PRIORITY_MEDIUM = 3;
    const TASK_PRIORITY_LOW = 4;

    //进度：1为正常，2为延期
    const TASK_PROGRESS_NORMAL = 1;
    const TASK_PROGRESS_DELAY  = 2;

    //任务状态：0为未开始，1为进行中，2为已完成，3为暂停
    const TASK_STATUS_READY = 0;
    const TASK_STATUS_ING   = 1;
    const TASK_STATUS_COMPLETE = 2;
    const TASK_STATUS_PAUSE = 3;

    static public $priority_list = [
        self::TASK_PRIORITY_EMERGENCY => '紧急',
        self::TASK_PRIORITY_HIGH => '高',
        self::TASK_PRIORITY_MEDIUM => '中',
        self::TASK_PRIORITY_LOW => '低',
    ];

    static public $progress_list = [
        self::TASK_PROGRESS_NORMAL => '正常',
        self::TASK_PROGRESS_DELAY  => '延期',
    ];

    static public $status_list = [
        self::TASK_STATUS_READY => '未开始',
        self::TASK_STATUS_ING   => '进行中',
        self::TASK_STATUS_COMPLETE => '已完成',
        self::TASK_STATUS_PAUSE => '暂停',
    ];

    static public $priority_color = [
        self::TASK_PRIORITY_EMERGENCY => 'danger',
        self::TASK_PRIORITY_HIGH => 'warning',
        self::TASK_PRIORITY_MEDIUM => 'primary',
        self::TASK_PRIORITY_LOW => 'success',
    ];

    static public $progress_color = [
        self::TASK_PROGRESS_NORMAL => 'green',
        self::TASK_PROGRESS_DELAY  => 'red',
    ];

    protected $table = 'member_task';

    protected $primaryKey = 'task_id';

    public function member()
    {
        return $this->hasMany(TaskMemberMap::class, 'task_id', 'task_id');
    }
}
